package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.dto.GoodsSalesDTO;
import com.sky.dto.OrdersPageQueryDTO;
import com.sky.entity.Orders;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;
import java.util.Map;

@Mapper
public interface OrderMapper {
    void insert(Orders orders);

    Page<Orders> pageQuery(OrdersPageQueryDTO pageQueryDTO);

    @Select("select * from orders where id=#{id}")
    Orders getById(long id);

    @Update("update orders set  status=#{status} where id=#{id}")
    void updateStatus(long id, Integer status);

    @Select("select count(id) from orders where status=#{status}")
    Integer countStatus(Integer status);

    void update(Orders orders);

    @Select("select * from orders where status=#{status} And order_time<#{orderTime}")
    List<Orders> getByStatusAndOrderTimeLT(Integer status, LocalDateTime orderTime);


    @Select("select * from orders where number=#{number} and user_id=#{userId}")
    Orders getByNumberAndUserId(String number, Long userId);

    Double sumByMap(Map map);

    Integer countByMap(Map map);

    List<GoodsSalesDTO> getTop10(LocalDateTime begin, LocalDateTime end);
}
